package com.hg.concurent.demo2;

import java.util.concurrent.BlockingQueue;

/**
 * @Author: skh
 * @Date: 2019/10/17 16:47
 * @Description:
 */
public class Consumer implements Runnable{
    private BlockingQueue<Integer> blockingQueue;

    public Consumer(BlockingQueue blockingQueue) {
        this.blockingQueue = blockingQueue;
    }



    @Override
    public void run() {
        while (true){
            Integer result = null;
            try {
                result = blockingQueue.take();
                System.out.println("消费者消费数据:" + result);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
